/**
 * Copyright 2010 Victor Egea Hernando
 *
 * RockScript is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 * 
 * RockScript is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with RockScript.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef OPCODES_H_
#define OPCODES_H_

#include <corelib/types.h>

// number of opcodes
#define NOPCODES 46

namespace paper
{

enum opcodes{
    // opcode flags
	OP_FLAG_TYPEB = 0x80,
    // mathematical opcodes (integer)
	OP_ADDI       = 13,
	OP_SUBI       = 14,
	OP_MULI       = 15,
	OP_DIVI       = 16,
	OP_MODI       = 17,
	OP_BWSHLI     = 18,
	OP_BWSHRI     = 19,
	OP_BWUSHRI    = 20,
	OP_BWANDI     = 21,
	OP_BWORI      = 22,
	OP_BWXORI     = 23,
	OP_BWNOTI     = OP_FLAG_TYPEB | 12,
	OP_ABSI       = OP_FLAG_TYPEB | 13,
	OP_INCI       = OP_FLAG_TYPEB | 14,
	OP_DECI       = OP_FLAG_TYPEB | 15,
    // loading / saving opcodes
    OP_MOVE       = 127,
    OP_SAVE       = OP_FLAG_TYPEB | 32,
	OP_LOAD       = OP_FLAG_TYPEB | 33,
	OP_LOADMK     = OP_FLAG_TYPEB | 34,
	OP_LOADCK     = OP_FLAG_TYPEB | 35,
	OP_LOADIA     = OP_FLAG_TYPEB | 36,
	OP_LOADIZ     = OP_FLAG_TYPEB | 37,
    // comparison opcodes
	OP_RCJMP      = OP_FLAG_TYPEB | 38,
	OP_RJMP       = OP_FLAG_TYPEB | 39,
	OP_NOT        = 29,
	OP_EQI        = 30,
	OP_EQR        = 31,
	OP_NEQI       = 32,
	OP_NEQR       = 33,
	OP_LTI        = 34,
	OP_LTR        = 35,
	OP_LEQI       = 36,
	OP_LEQR       = 37,
	OP_GTI        = 38,
	OP_GTR        = 39,
	OP_GEI        = 40,
	OP_GER        = 41,
    // method opcodes
	OP_LOADARG    = 120,
	OP_KCCALL     = OP_FLAG_TYPEB | 121,
	OP_UCCALL     = OP_FLAG_TYPEB | 122,
	OP_CPPCODE    = OP_FLAG_TYPEB | 123,
	OP_RETURN     = OP_FLAG_TYPEB | 124,
    // object opcodes
	OP_NEW        = OP_FLAG_TYPEB | 80,
    OP_DELETE     = 80
};

};

#endif // OPCODES_H_
